<template>
    <div>
        <button @click="sendMessage">AppHeader send message</button>
    </div>
</template>

<script>
import eventBus from '../util/eventBus'

export default {
    data() {
        return {
            title: '这是一个事件总线的订阅发布案例',
            student: {
                name: '小华',
                age: 32,
                gender: '男'
            }
        }
    },
    methods: {
        sendMessage() {
            console.log('AppHeader.vue sendMessage')
            // 发送事件，传递消息
            eventBus.emit('sendData', {
                title: this.title,
                student: this.student
            });
        }
    },
}
</script>